<script type="text/javascript"> 

$(document).ready(function() { 
    $('#sugestions').text('Processing...');
    $('#sugestions').load( "getAllSugestions" ); 
}); 

$(document).ready(function(){
//    $("#exemplequery").hide();
    $("#exemplelink").click(function () {
        $("#exemplequery").slideToggle("slow");
    });
});

function unselectAll(){
    $(document).ready( function(){
       $("input.restrict").removeAttr( "checked" );
    });
}
function selectAll(){
    $(document).ready( function(){
       $("input.restrict").attr( "checked", "checked" );
    });
}

function selectGenre( genre ){
    $(document).ready( function(){
        if( $("span[genre="+genre+"] input").attr("check")){
           $("span[genre="+genre+"] input").removeAttr( "check" );
           $("span[genre="+genre+"] input").removeAttr( "checked" );
        }
        else{
            $("span[genre="+genre+"]  input").attr("check", "check");
            $("span[genre="+genre+"]  input").attr("checked", "checked");
        }
    });
}

</script>
<!-- MENU : BEGINNING______________________________________________________________________ -->
<!-- <a href="home" class="path" title="Go home">Home</a> -->
<center> <b> Home </b> </center>
<a href="." class="path" title="Go to upload collection page">Upload Collection</a>
<a href="help" class="path" title="(?) Help contents">Help Contents</a>
<a href="about" class="path" title="About PhyloExplorer project...">About</a>
<br />
<center> <b>Current collection</b> </center>
<a href="/check" blockui="wait" class="path" title="Go back to collection"> Browse collection </a>
<a href="/downloadNCBITree" class="path" title="Download the NCBI arborescence">
Download NCBI tree </a>
<a href="/downloadCollection" class="path" title="Download the (full or filtered) collection">Download collection</a>
<br />
<!-- MENU : END -->
     </td>
             <td class="content">
            <a href="#bottom" class="posPage">&nbsp;Go to bottom&nbsp;</a>
            <br />
<!-- CONTENU : BEGINNING____________________________________________________________________ -->
<div class="stat">
<!-- query panel -->
<div class="query">
<form action="statistics" class="nopadding">
<!-- <a onclick="javascript:toggleExemple();" id="exemplelink"> View exemple
</a>&nbsp; -->
<input size=60  type=text 
onfocus="if(this.value=='Your query...'){this.value='';}" 
onblur="if(this.value==''){this.value='Your query...';}"
<%
if _query_:
    #
%>
value="<%$ _query_ %>"
<%
else:
    #
%>
value="Your query..."
<%|%>
name="query" /> 
<input type="submit" value="Search" class="button" blockui="wait"> <br>
<tt id="exemplequery"> e.g: <b> {murinae} > 2 and {carnivora}==1 and not ({primates} or {laurasiatheria} < 4) </b>
<br /> 
<i>You can download your result after your query</i></tt>
</form>
<%
if _query_:
    #
%>
    Results for --&nbsp;<%$ _query_ %>&nbsp;--&nbsp;|&nbsp;<a blockui="wait" href=statistics?clear_query=1>Back to full collection</a>
<%
else:
    _query_ = ""
#
%>
</div>

<%
if _msg_:
    #
%>
    <div  class="error"><%$ _msg_ %></div>
<%|%>
</div>
<%
if len( _collection_ ) == 0:
    #
%>
   <div class="error">Empty collection</div>
<%
else:
    #
%>
<!-- end query panel -->
    <br />
    <a name="arbo"></a>
    <fieldset>
        <legend> General information </legend>
        <%$ _nbtree_ %> trees <br />
        <%$ _nbtaxa_ %> taxa &nbsp;
<%
    if len(_badtaxalist_):
        #
%>
        <font color="red"> <%$ len(_badtaxalist_)%> bad taxa </font>&nbsp;
<%
    if len(_homonymlist_):
        #
%>
        <font color="orange"><%$ len(_homonymlist_)%> homonyms </font>
    <%|%>
    </fieldset><br />

<!-- correct collection fieldset -->
<%
    if len(_badtaxalist_) or len(_homonymlist_):
        #
%>
        <fieldset>
        <legend> Correct your collection </legend>
        <form action="recreateCollection">
        <!-- badtaxa fieldset -->
<%
        if len(_badtaxalist_):
            #
%>
        <fieldset class="sugestions">
            <legend> <%$ len( _badtaxalist_)%> bad taxa </legend>
            <span id="sugestions"> </span>
            <span id="graph"> </span>
        </fieldset>
        <!-- end badtaxa fieldset -->
        <%|%>
        <!-- homonym fieldset -->
<%
        if len(_homonymlist_):
            #
%>
            <span class="homonymlist">
            <fieldset>
            <legend> <%$ len(_treecollection_.homonyms.keys()) %> homonym(s) </legend>
<%
            for homonym, taxa in _treecollection_.homonyms.iteritems():
                #
%>
                <font color="orange"><%$ homonym %></font> :
<%
                for taxon in taxa:
                    dispnode = taxon.split("|")[0].replace(_treecollection_.reference.delimiter, " ")
                    dispnode = dispnode.replace( "<", "&lt;" )
                    dispnode = dispnode.replace( ">", "&gt;" )
                    #
%>
                    <%$ _treecollection_._TreeCollection__linkSpecies( dispnode, taxon) %>
                    <input type="radio" name="<%$ homonym %>" value="<%$ dispnode %>" />
                <%|%>
                <br />
            <%|%>
            </fieldset>
            </span>
        <!-- end homonym fieldset -->
        <%|%>
        <input type="submit" value="Correct collection"/>
        </form>
        </fieldset><br />
    <%|%>
<!-- end collection fieldset -->

<!-- stat1 -->
    <fieldset>
        <legend> Tree size distribution </legend>
        <%$ _stat1_ %>
    </fieldset>
<!-- end stat1 -->

<!-- stat2 -->
    <fieldset>
        <legend> Taxon frequency distribution </legend>
        <tt>
        <%$ _stat2_ %>
        </tt>
    </fieldset><br />
<!-- end stat2 -->

<!-- NCBI tree -->
    <fieldset>
        <legend> NCBI taxonomy</legend>
        <a target="_blank" style="color:green"
        href="http://www.phylowidget.org/full/index.html?tree='<%$ _NCBItree_ %>'"
        title="Display the ncbi tree as graph"> Click to visualize this tree using PhyloWidget </a>
        <br />
        <br />
        <form action="createFilteredCollection">
            <a class="selectall" onclick="javascript:selectAll();"> Select all</a> &nbsp; &nbsp;
            <a class="selectall" onclick="javascript:unselectAll();"> Unselect all </a>
            <br />
            <tt>
            <%$ _ncbitree_ %>
            </tt>
        <b> Select the taxa you want to exclude and </b> <br />
        <input type="submit" value="Restrict your trees" />
        </form>
    </fieldset><br />
<!-- end NCBI tree -->
<%|%>
</div>
            <a href="#top" class="posPage">&nbsp;Go to top&nbsp;</a>
    <!-- div preview -->
    <div id="preview"></div>
<!-- CONTENT : END -->
